﻿Imports System.Text

Public Class xtf_direccionMap

    Private Sub xtf_direccionMap_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Try
            Dim streetaddr As String = ""
            Dim cityaddr As String = ""
            Dim stateaddr As String = ""
            Dim zipaddr As String = ""
            Dim AddrToSearch As New StringBuilder()
            AddrToSearch.Append("http://maps.google.com/maps?q=")

            ' if there is street entry
            streetaddr = InputBox("streetaddr")
            streetaddr = streetaddr.Replace(" ", "+")
            AddrToSearch.Append(streetaddr + "," & "+")

            ' if there is city entry
            cityaddr = InputBox("cityaddr")
            cityaddr = cityaddr.Replace(" ", "+")
            AddrToSearch.Append(cityaddr + "," & "+")

            ' if there is state
            stateaddr = InputBox("stateaddr")
            stateaddr = stateaddr.Replace(" ", "+")
            AddrToSearch.Append(stateaddr + "," & "+")

            ' if there is zip code
            zipaddr = InputBox("zipaddr")
            zipaddr = zipaddr.ToString()
            AddrToSearch.Append(zipaddr)

            ' pass the AddrToSearch value to web browser control
            wbrowser.Navigate(AddrToSearch.ToString())

        Catch ex As Exception

            MessageBox.Show(ex.Message.ToString(), "Problem encountered while retrieving google map")

        End Try
        'Try
        'Dim latitude As String = ""
        'Dim longitude As String = ""
        'Dim AddrToSearch As New StringBuilder()
        'AddrToSearch.Append("http://maps.google.com/maps?q=")

        '    ' if there is latitude
        '    If txtLatitude.Text <> "" Then
        '        latitude = txtLatitude.Text
        '        AddrToSearch.Append(latitude & "%2C")
        '    End If

        '    ' if there is longitude
        '    If txtLongitude.Text <> "" Then
        '        longitude = txtLongitude.Text
        '        AddrToSearch.Append(longitude)
        '    End If

        '    ' pass the AddrToSearch value to web browser control
        '    wbrowser.Navigate(AddrToSearch.ToString())

        'Catch ex As Exception

        '    MessageBox.Show(ex.Message.ToString(), "Problem encountered while retrieving google map")

        'End Try

    End Sub
End Class